package top.infopub.job.quartz.exec;


import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import top.infopub.job.cap.service.LoanContractInterestService;
import top.infopub.job.quartz.exec.base.BaseJob;
import top.infopub.util.DateUtil;
import top.infopub.util.SpringContext;


/**
 * 借款合同定时任务
 * 月初统计上一个月的
 *
 * @author wangkai
 * @version 2021年6月5日
 * @see
 * @since
 */
public class LoanContractJob extends BaseJob {

    private static LoanContractInterestService loanContractInterestService;


    static {
        loanContractInterestService = SpringContext.getBean(LoanContractInterestService.class);
    }

    public LoanContractJob() {
    }

    @Override
    public void execute(JobExecutionContext arg0)
            throws JobExecutionException {
        try {
            String start = DateUtil.currentDateDef();
            log.info("LoanContractJob开始时间：{}", start);
            loanContractInterestService.updateInterestRate();
            String end = DateUtil.currentDateDef();
            log.info("LoanContractJob结束时间：{}", end);
            logSucceed("LRP利率计算更新任务执行完成，开始时间：" + start + "，结束时间：" + end);
        } catch (Exception e) {
            log.error("借款合同定时任务执行error", e);
            logFail(e, true);
        }

    }

}
